package com.zxjbyte.yiyi.framework.oss.event;

import com.google.common.eventbus.Subscribe;
import com.zxjbyte.yiyi.framework.common.core.eventbus.EventSubscriber;
import com.zxjbyte.yiyi.module.system.api.oss.OssRecordApi;
import lombok.RequiredArgsConstructor;

/**
 * 这里记录Oss上传日志记录使用spring机制的好处是：
 *
 * 可以提供松耦合、简化代码、增强可扩展性和可测试性等，使得应用程序更加灵活、可维护和可扩展
 * @Author zhangxingjia
 * @Date 2023/6/26 15:14
 * @Version: 1.0
 */
@RequiredArgsConstructor
@EventSubscriber(async = true)
public class OssRecordListener {

    private final OssRecordApi ossRecordApi;

    @Subscribe
    public void addOperateLog(OssRecordAddEvent event) {
        ossRecordApi.asyncAdd(event.getAddDto());
    }


    @Subscribe
    public void deleteOperateLog(OssRecordDeleteEvent event) {
        ossRecordApi.asyncDeleteByPath(event.getDelDto());
    }
}
